package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.BannerJumpDO;
import com.starlink.model.request.BannerJumpRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface BannerJumpMapper extends BaseMapper<BannerJumpDO> {
    BannerJumpDO selectDOById(Long id);
    List<BannerJumpDO> selectDOList(BannerJumpDO bannerJump);
    int insertDO(BannerJumpDO bannerJump);
    int batchInsertDO(List<BannerJumpDO> bannerJumpDOList);
    int updateDO(BannerJumpDO bannerJump);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from banner_jump",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") BannerJumpRequest param);
    @Select({"<script>",
            "   select * from banner_jump",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<BannerJumpDO> pageQuery(@Param("param") BannerJumpRequest param, @Param("limit") int limit, @Param("offset") long offset);
}
